package com.tcwlkj.uuService.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.tcwlkj.uuService.fragment.NotSnatchOrder_Fragment;
import com.tcwlkj.uuService.fragment.RealtimeOrder_Fragment;
import com.tcwlkj.uuService.fragment.WaitOrder_Fragment;

/**
 * Created by Administrator on 2017/9/30 0030.
 */

public class VP_Adapter extends FragmentPagerAdapter {

    private final int PAGE_COUNT = 3;
    private Context mContext;
    RealtimeOrder_Fragment realtimeOrder_fragment;
    NotSnatchOrder_Fragment notSnatchOrder_fragmen;
    WaitOrder_Fragment waitOrder_fragment;

    public VP_Adapter(FragmentManager fm,Context mContext) {
        super(fm);
        this.mContext=mContext;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment=null;
        switch (position){
            case 0:
                if(realtimeOrder_fragment==null){
                    realtimeOrder_fragment=new RealtimeOrder_Fragment();
                }
                fragment=realtimeOrder_fragment;
                break;
            case 1:
                if(notSnatchOrder_fragmen==null){
                    notSnatchOrder_fragmen=new NotSnatchOrder_Fragment();
                }
                fragment=notSnatchOrder_fragmen;
                break;
            case 2:
                if(waitOrder_fragment==null){
                    waitOrder_fragment=new WaitOrder_Fragment();
                }
                fragment=waitOrder_fragment;
                break;
            default:
                break;
        }
        return fragment;
    }

    @Override
    public int getCount() {
        return PAGE_COUNT;
    }
}
